home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 3: The Continuation / 17-Bit_The_Continuation_Disc.iso / amigan / amigan 4 / make / make.doc < prev    next >
Encoding:
Text File  |  1994-01-27  |  5.5 KB  |  103 lines

  1. MAKE:  Brought to you by John Toebes and Jack Rouse of
  2.  
  3. |_o_o|\\   The           Dave Baker    Ed Burnette
  4. |. o.| ||   Software     Stan Chow     Jay Denebeim
  5. | .  | ||    Distillery  Gordon Keener Jack Rouse
  6. | o  | ||                John Toebes   Doug Walker
  7. |  . |//
  8. ======     BBS:(919)-471-6436   300/1200/2400
  9.  
  10. US Snail:
  11. The Software Distillery
  12. 235 Trillingham Lane
  13. Cary, NC 27511
  14.  
  15. USENET:
  16. mcnc!rti-sel!sas!toebes
  17.  
  18. =========================================================================
  19.  
  20.      MAKING IT WITH MAKE        MAKE is a UN*X utility which allows you to keep
  21.                                 track of your source files no matter how large
  22.   For the Lazy and Ingenious    or complicated your project gets. Suppose you
  23.                                 have two source files for a C program: main.c
  24. and subs.c. Let's also say they both #include foofile.h. If you change main.c,
  25. you must recompile main.c and relink.  If you change foofile.h, you must re-
  26. compile both main.c and subs.c.  This isn't too bad with only two files, but
  27. just try to keep track of, say, eight source files...ten...a hundred. MAKE is
  28. designed to help you whether you have one, ten, or one hundred source files.<
  29.  
  30. The principle behind MAKE is that you specify all the commands required to pro-
  31. duce your program in a file (called 'makefile').  When you want to produce an
  32.                                        up-to-date version of your program, you
  33. program: main.o subs.o                 simply type 'make'; MAKE looks at the
  34.  blink from main.o,subs.o to program   system dates on your source files, de-
  35.  echo "all done!"                      termines which must be recompiled, then
  36.                                        recompiles them and relinks your execut-
  37. main.o: main.c foofile.h               able! A makefile for our simple program
  38.  lc main.c                             with two source files is shown at left.
  39.  
  40. subs.o: subs.c foofile.h               This simple script tells MAKE that the
  41.  lc subs.o                             file PROGRAM depends (:) on the files
  42.                                        main.o and subs.o, and that to make the
  43. file PROGRAM you execute the 'blink' command on the second line.  You can have
  44. as many filenames separated by blanks as you wish after the colon.  Commands,
  45. if present, must start with a blank or tab.  You may have as many commands as
  46. you wish.
  47.  
  48. Note that there are entries for main.o, subs.o, and foofile.h. MAKE will see
  49. that PROGRAM depends on main.o, and main.o depends on main.c; it will check the
  50. dates on main.o and main.c to see if the 'lc main.c' (compile) command should
  51. be performed before it links PROGRAM.
  52.  
  53. Instead of entering an lc command for each .c file you have, you can instead
  54. enter a special dependency that looks like the one at left, below. This tells
  55.            MAKE that whenever it sees an .o file, it must see a dependency upon
  56. .c.o:      a .c file with the same prefixed name. You are relieved of any need
  57.  lc $*.c   to put this dependency in every makefile; instead, MAKE allows you
  58.            to put it in a file called "builtins.make" in your C: directory. If
  59. the expression "$*" is seen in a builtin dependency, MAKE replaces it with the
  60. file name being processed (minus the .c or .o extension, of course).
  61.  
  62. Now that your makefile is entered, how do you use it to make PROGRAM?  Quite
  63. simple.  Just type 'make'.  MAKE looks in the makefile and sees that PROGRAM is
  64. the first file listed; it therefore assumes that you mean to make PROGRAM. It
  65. then does whatever is necessary to bring PROGRAM up to date.  But what if you
  66. just want to compile 'main.c'?  Also simple. Type 'make main.o'. MAKE takes the
  67. argument and figures out how to make it from the makefile.
  68.  
  69. In fact, if you have typed in the .c.o dependency above, you can MAKE FARKLE.O
  70. when FARKLE is not even mentioned in the makefile.  As you can see, MAKE is
  71. worth its weight in saved keystrokes alone!
  72.  
  73. There are several useful command line options on MAKE: "make -n ..." prints the
  74. commands needed to bring "file" up to date to the screen but will not execute
  75. them.  This is great if you just want to see how out-of-date your stuff is. A
  76. "make -k ..." tells MAKE that it should proceed as far as it can without stop-
  77. ping.  If a command fails, MAKE quits without this flag; with the flag, MAKE
  78. continues until it needs the output file from the failed command.
  79.  
  80. This means that if you compile 50 files and number 27 fails, numbers 28 to 50
  81. are compiled before MAKE needs the .o file for number 27. Last, "make -f <file-
  82. name>" tells MAKE to get its instructions from <filename>, not from "makefile."
  83.  
  84. MAKE observes ^C interrupts; hit ^C and everything stops.  It also observes ^D
  85. interrupts;  hit ^D and MAKE quits after the current command is executed.<
  86.  
  87.  FOR THE ADVANCED USER:  There is a limited ability to define macros in a make-
  88. file. Macros are of the form NAME = STRING. Whenever the string $(NAME) is seen
  89.                  in a makefile, STRING is put in its place. For example, you
  90. LC = lc $*       can use the macros at left. This allows you to change your de-
  91. LCD = lc -d $*   fault compiler options rapidly by simply changing the last line
  92. .c.o:            to read $(LCD) [with a -d option] in place of $(LC).
  93.  $(LC)
  94.                  Normally, MAKE types each line to the screen before executing
  95. it. If you prefer silent execution, preface a command with an '@'. Example:<
  96.  
  97. program: program.o
  98.  @echo "Linking program. . ."
  99.  @blink from lib:c.o,program.o to program verbose lib lib:lc.lib
  100.  
  101. Enjoy MAKE as much as I do!  Many thanks to John Toebes and Jack Rouse for MAKE-
  102. ing it available!
  103.